package Arraysearchdemo;
import java.util.Scanner;
public class Arraysearchdemo {
    public static void main(String[]args) {
        System.out.println("输入要查找的数");

        int low,high,mid;
        Scanner sc=new Scanner(System.in);
        int k=sc.nextInt();//接收的数

        int[] arr={1,4,7,10,13,15,21,25};
        low=0;
        high=7;

        if(low<high) {
            mid=(low+high)/2;
            if(k<arr[mid]) {
                high=mid-1;
            }
            else if(k>arr[mid]) {
                low=mid+1;
            }
            else {
                System.out.println("所输入的数所占的是集合中第"+mid+"元素");

            }
        }
        else {
            System.out.println("所查找的元素不存在集合中");
        }
    }


}

